package software_construction.calcu_05_demo.equation;

public class AddEquation extends Equation {

    public AddEquation() {
        super("+");
    }

    public AddEquation(String equationStr) {
        int index = equationStr.indexOf("+");
        int length = equationStr.length();
        this.setLeftNum(Integer.parseInt(equationStr.substring(0,index)));
        this.setRightNum(Integer.parseInt(equationStr.substring(index+1,length-1)));
        this.setOp("+");
        this.setResult(calculate());
    }


    @Override
    protected int calculate() {
        return this.getLeftNum()+this.getRightNum();
    }
}
